﻿Imports System.Windows.Forms

Public Class frmNewTask

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Dim erro As Boolean = False
        If (txtDesrciption.Text = "") Then
            MessageBox.Show("Task Description missing")
            erro = True
        End If
        If (erro = False) Then
            Try
                Dim _toDo As New Todo()
                _toDo.Task = txtDesrciption.Text
                _toDo.IsPrivate = CheckBoxPrivate.Checked
                _toDo.Note = txtNotes.Text
                _toDo.Pri = priority()
                'If (txtCategory.Text <> "") Then
                _toDo.Category = txtCategory.Text
                'End If
                _toDo.save()
                Me.DialogResult = System.Windows.Forms.DialogResult.OK
                Me.Close()
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End If
    End Sub

    Private Function priority() As Byte
        If (RadioHigh.Checked = True) Then
            Return 0
        ElseIf (RadioLow.Checked = True) Then
            Return 2
        ElseIf (RadioNormal.Checked = True) Then
            Return 1
        End If
    End Function

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEsc.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub btnCategory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCategory.Click
        Dim frm As New frmEditCategory()
        If (frm.ShowDialog() = Windows.Forms.DialogResult.OK) Then

        End If
    End Sub
End Class
